home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume1 / craps < prev    next >
Encoding:
Text File  |  1987-05-09  |  37.8 KB  |  1,764 lines

  1. Path: seismo!gatech!hao!ames!ucbcad!ucbvax!decvax!tektronix!tekgen!tekred!games-request
  2. From: games-request@tekred.TEK.COM
  3. Newsgroups: comp.sources.games
  4. Subject: v01i009:  craps - a card game for curses
  5. Message-ID: <1197@tekred.TEK.COM>
  6. Date: 8 May 87 23:59:49 GMT
  7. Sender: billr@tekred.TEK.COM
  8. Lines: 1753
  9. Approved: billr@tekred.TEK.COM
  10.  
  11. Submitted by: ray@jimi.UUCP
  12. Mod.sources.games: Volume 1, Issue 9
  13. Archive-name: craps
  14.  
  15. #! /bin/sh
  16. # This is a shell archive, meaning:
  17. # 1. Remove everything above the #! /bin/sh line.
  18. # 2. Save the resulting text in a file.
  19. # 3. Execute the file with /bin/sh (not csh) to create the files:
  20. #    Makefile
  21. #    README
  22. #    craps.6
  23. #    dont.c
  24. #    etc.c
  25. #    final.c
  26. #    help.c
  27. #    main.c
  28. #    makeb.c
  29. #    pass.c
  30. #    pay.c
  31. #    prints.c
  32. #    props.c
  33. #    random.c
  34. #    subs.c
  35. #    ext.h
  36. #    types.h
  37. # This archive created: Thu May  7 17:53:18 1987
  38. # By:    Ray Tripamer (Applied Systems Consultants, Inc.  Las Vegas)
  39. export PATH; PATH=/bin:$PATH
  40. if test -f 'Makefile'
  41. then
  42.     echo shar: will not over-write existing file "'Makefile'"
  43. else
  44. cat << \SHAR_EOF > 'Makefile'
  45. SOURCES =    main.c dont.c etc.c help.c makeb.c pass.c pay.c prints.c \
  46.         props.c subs.c final.c random.c
  47. OBJECTS =    main.o dont.o etc.o help.o makeb.o pass.o pay.o prints.o \
  48.         props.o subs.o final.o random.o
  49. #
  50. # Use the following defines:
  51. #
  52. #    -DBSD42        for Berkeley Unix 4.2
  53. #    -DBSD29        for Berkeley Unix 2.9
  54. #    -DSYSV        for System V machines
  55. #    -DXENIX        for Xenix Machines
  56. #    -DSCORES    to maintain a high score list
  57. #
  58. CFLAGS  =    -O -DXENIX -DSCORES
  59.  
  60. #
  61. # if you are using BSD29, then add the -i option to the cc line
  62. #
  63. craps:    ${OBJECTS}
  64.     cc ${CFLAGS} -s -i -o craps ${OBJECTS} -lcurses -ltermlib -lm
  65.  
  66. main.o:        main.c types.h
  67. dont.o:        dont.c types.h ext.h
  68. etc.o:        etc.c types.h ext.h
  69. help.o:        help.c types.h ext.h
  70. makeb.o:    makeb.c types.h ext.h
  71. pass.o:        pass.c types.h ext.h
  72. pay.o:        pay.c types.h ext.h
  73. prints.o:    prints.c types.h ext.h
  74. props.o:    props.c types.h ext.h
  75. subs.o:        subs.c types.h ext.h
  76. final.o:    final.c types.h ext.h
  77. random.o:    random.c types.h ext.h
  78.  
  79. clean:
  80.     rm -f craps *.o
  81. SHAR_EOF
  82. fi # end of overwriting check
  83. if test -f 'README'
  84. then
  85.     echo shar: will not over-write existing file "'README'"
  86. else
  87. cat << \SHAR_EOF > 'README'
  88.  
  89.             Some Notes on Installing Craps
  90.  
  91.     Craps is known to run on BSD2.x and BSD4.x.  If you are running
  92.     on another UN*X operating system, then is is imperative that
  93.     you have a curses library, or forget using this program.
  94.     Also, for other systems, the file random.c will have to be
  95.     modified for your local random number generator.
  96.  
  97.     The routine seedrand() seeds the random number generator, and
  98.     get_rand() returns an random integer between 1 and 6.
  99.  
  100.     The high roller list uses the system library function qsort(3),
  101.     so if your system doesn't have it, it must be supplied, or, as an
  102.     alternative, just comment out the "#define SCORES" from the file
  103.     "types.h"
  104.  
  105.     Also, you will have to specify the path for the high roller
  106.     file, "craps_list", if the define "#define SCORES" is present.
  107.     It should go in /usr/games/lib.  The name of the directory
  108.     is in the file "final.c"
  109. SHAR_EOF
  110. fi # end of overwriting check
  111. if test -f 'craps.6'
  112. then
  113.     echo shar: will not over-write existing file "'craps.6'"
  114. else
  115. cat << \SHAR_EOF > 'craps.6'
  116. .TH CRAPS 6
  117. .UC 4
  118. .SH NAME
  119. craps \- play the game of craps
  120. .SH SYNOPSIS
  121. .B /usr/games/craps
  122. .SH DESCRIPTION
  123. .PP
  124. .I Craps
  125. is the popular gambling game found in most casinos, legal or otherwise,
  126. and is now found on the system.  Although craps has many betting options,
  127. it is beyond the scope of this manual to explain every possible bet.
  128. .PP
  129. To get started you really only need to know one command.  The command
  130. .B ?
  131. will give you a list of the available commands.  Another useful tip
  132. is that the <ESC> key will abort any command, and return you to
  133. the 'bet:' prompt.
  134. .PP
  135. The object of craps is to (of course) beat the house, i.e. leave the
  136. game with more money than when you started.
  137. .PP
  138. A "high rollers" list is maintained which keeps track of the amount won by
  139. each person who has played, and also the number of games they have played.
  140. It is highly likely that over the long run, the player on the top of the
  141. list is the one who has lost the least amount of money!
  142. .SH ENVIRONMENT
  143. .PP
  144. CRAPSNAME - used to set your name on the High Rollers List.
  145. .SH AUTHOR
  146. .PP
  147. Ray Tripamer, University of Nevada, Las Vegas
  148. :-)
  149. .SH FILES
  150. .DT
  151. /usr/games/lib/craps.list\ \ \ High Roller List
  152. .br
  153. .SH SEE ALSO
  154. "Playboy\'s Guide to Casino Craps"
  155. .SH BUGS
  156. .PP
  157. If any should arise, please mail them to
  158. me at: !seismo!unrvax!unlv!ray
  159. SHAR_EOF
  160. fi # end of overwriting check
  161. if test -f 'dont.c'
  162. then
  163.     echo shar: will not over-write existing file "'dont.c'"
  164. else
  165. cat << \SHAR_EOF > 'dont.c'
  166. #include "types.h"
  167. #include "ext.h"
  168.  
  169. pdontln()    /* pay the dont pass line */
  170. {
  171.     double bet(),x;
  172.  
  173.     x=dont+bet(lodds[point],op[point][1],op[point][0]);
  174.     total=total+x+lodds[point];
  175.     wins=wins+x;
  176.     if(dont!=0.0) {
  177.         sprintf(line,"You won %.2f on the Dont Pass! ~",x);
  178.         announce(line);
  179.     }
  180.     lodds[point]=0.0;
  181. }
  182.  
  183. cdontln()    /* clear the dont pass line */
  184. {
  185.     loss=loss+dont+lodds[point];
  186.     if(dont!=0.0) announce("You lost on Dont Pass! ~");
  187.     dont=0.0;
  188.     lodds[point]=0.0;
  189. }
  190.  
  191. pdontb()    /* pay the dont bar */
  192. {
  193.     total=total+dcomeb;
  194.     wins=wins+dcomeb;
  195.     if(dcomeb!=0.0) announce("You won your Dont Come Bet! ~");
  196. }
  197.  
  198. cdontb()    /* clear the dont bar */
  199. {
  200.     loss=loss+dcomeb;
  201.     if(dcomeb!=0.0) announce("You lost your Dont Come Bar Bet! ~");
  202.     dcomeb=0.0;
  203. }
  204.  
  205. pdonts()    /* pay all of the dont come points */
  206. {
  207.     int i,j=0;
  208.     double x=0.0,bet();
  209.  
  210.     for(i=0;i<11;i++) {
  211.         x=x+dcome[i]+bet(lodds[i],op[i][1],op[i][0]);
  212.         total=total+dcome[i]+lodds[i];
  213.         if(dcome[i]!=0.0) j++;
  214.         dcome[i]=lodds[i]=0.0;
  215.     }
  216.     sprintf(line,"You won %.2f on your Dont Come Bet%s~",x,(j==1)?". " :"s. ");
  217.     if(j) announce(line);
  218.     total=total+x;
  219.     wins=wins+x;
  220. }
  221.  
  222. csdont(n,off)    /* clear a single dont come bet */
  223. int n,off;
  224. {
  225.     loss=loss+dcome[n]+lodds[n];
  226.     if(dcome[n]!=0.0) announce("Down in Back! ~");
  227.     dcome[n]=lodds[n]=0.0;
  228. }
  229.  
  230. do_dont(n)
  231. int n;
  232. {
  233.     dcome[n]=dcomeb;
  234.     if(dcomeb!=0.0) {
  235.         sprintf(line,"Dont Come moved behind the %d. ~",n);
  236.         announce(line);
  237.     }
  238.     dcomeb=0.0;
  239. }
  240. SHAR_EOF
  241. fi # end of overwriting check
  242. if test -f 'etc.c'
  243. then
  244.     echo shar: will not over-write existing file "'etc.c'"
  245. else
  246. cat << \SHAR_EOF > 'etc.c'
  247. #include "types.h"
  248. #include "ext.h"
  249.  
  250. pplace(n)    /* pay a place bet */
  251. int n;
  252. {
  253.     double bet(),x;
  254.  
  255.     x=bet(place[n],plcpays[n][0],plcpays[n][1]);
  256.     total=total+x;
  257.     wins=wins+x;
  258.     if(place[n]!=0.0) {
  259.         sprintf(line,"You hit your place bet for %.2f! ~",x);
  260.         announce(line);
  261.     }
  262. }
  263.  
  264. move_place(n)
  265. int n;
  266. {
  267.     if(place[n]!=0.0) {
  268.         announce("Your place bet is off on the Comeout! ~");
  269.         if(pass!=0.0) {
  270.             announce("Your place bet is in your Tray. ~");
  271.             total=total+place[n];
  272.             place[n]=0.0;
  273.         }
  274.     }
  275. }
  276.  
  277. cplace()    /* clear all place bets */
  278. {
  279.     int i,j=0;
  280.     char line[81];
  281.  
  282.     for(i=0;i<11;i++) { 
  283.         if(place[i]!=0.0) j++;
  284.         loss=loss+place[i];
  285.         place[i]=0.0;
  286.     }
  287.     if(j) {
  288.         sprintf(line,"You lost your Place Bet%s~",(j>1)?"s. ":". ");
  289.         announce(line);
  290.     }
  291. }
  292.  
  293. pfield()
  294. {
  295.     double x;
  296.  
  297.     x=fpays[sum]*field;
  298.     if(x==0.0) {
  299.         loss=loss+field;
  300.         if(field) announce("You lost your Field Bet! ~");
  301.         field=0.0;
  302.     } else {
  303.         wins=wins+x;
  304.         field=field+x;
  305.         if(field>LIMIT) {
  306.             total=total+(field-LIMIT);
  307.             field=LIMIT;
  308.         }
  309.         if(field) {
  310.             sprintf(line,"You won%s in the field! ~",
  311.                 (sum==2||sum==12)?
  312.                 ((sum==12)?" Triple":" Double"):" ");
  313.             announce(line);
  314.         }
  315.     }
  316. }
  317.  
  318. chk_hrd(x)
  319. int x;
  320. {
  321.     return((x==4)||(x==6)||(x==8)||(x==10));
  322. }
  323.  
  324. chk_plc(x)
  325. int x;
  326. {
  327.     return((x==4)||(x==5)||(x==6)||(x==8)||(x==9)||(x==10));
  328. }
  329.  
  330. d_or_p(x)
  331. int x;
  332. {
  333.     if(!x) return(0);
  334.     if(dont==0.0 && x==point) {
  335.         msg("You must have a dont pass bet to lay odds.",23,1);
  336.         return(1);
  337.     } else if(dcome[x]==0.0 && x!=point) {
  338.         sprintf(line,"You don't have a dont come bet on %d.",x);
  339.         msg(line,23,1);
  340.         return(1);
  341.     } else return(0);
  342. }
  343.  
  344. c_or_p(x)
  345. int x;
  346. {
  347.     if(!x) return(0);
  348.     if(pass==0.0 && x==point) {
  349.         msg("You must have a pass line bet to take odds.",23,1);
  350.         return(1);
  351.     } else if(come[x]==0.0 && x!=point) {
  352.         sprintf(line,"You don't have a come bet on %d",x);
  353.         msg(line,23,1);
  354.         return(1);
  355.     } else return(0);
  356. }
  357. SHAR_EOF
  358. fi # end of overwriting check
  359. if test -f 'final.c'
  360. then
  361.     echo shar: will not over-write existing file "'final.c'"
  362. else
  363. cat << \SHAR_EOF > 'final.c'
  364. #include "types.h"
  365. #include "ext.h"
  366. #include <stdio.h>
  367. #include <sys/types.h>
  368. #include <sys/file.h>
  369.  
  370. /*
  371.  *
  372.  * here is the file name for the high roller list.
  373.  * It will need to be modified for your system.
  374.  *
  375.  */
  376.  
  377. char *sfile="/usr/games/lib/craps.list";
  378. char *reclock="/usr/games/lib/craps.lock";
  379.  
  380. #ifdef    SCORES
  381. #define    NAMELEN        40
  382. typedef struct node {
  383.     struct node *next;
  384.     int uid;
  385.     long ngames;
  386.     double amt;
  387.     char name[NAMELEN+1];
  388. } scores;
  389. #endif
  390.  
  391. final(d)
  392. int d;
  393. {
  394. #ifdef    SCORES
  395.     FILE *list;
  396.     int f,sleepct=300,cuid,did=0,i,n=0,comp(),nchars;
  397.     long l;
  398.     double x;
  399.     char s[NAMELEN+1],c;
  400.     scores *score;
  401.  
  402.     cuid=getuid();
  403.     clear(); refresh();
  404.     signal(SIGHUP,SIG_IGN);
  405.     signal(SIGINT,SIG_IGN);
  406.     while(link(sfile, reclock) == -1) {
  407.         perror(reclock);
  408.         if(!sleepct--) {
  409.             puts("I give up. Sorry.");
  410.             puts("Perhaps there is an old record_lock around?");
  411.             exit(-1);
  412.         }
  413.         printf("Waiting for access to record file. (%d)\n",
  414.             sleepct);
  415.         fflush(stdout);
  416.         sleep(1);
  417.     }
  418.     if((list=fopen(sfile,"r"))==NULL) {
  419.         fprintf(stderr,"can't open %s\n",sfile);
  420.         myexit();
  421.         return(0);
  422.     }
  423.     while((c=fgetc(list))!=EOF) if(c=='\n') n++;
  424.     rewind(list);
  425.     score=(scores *)malloc((n+1)*sizeof(scores));
  426.     cuid=getuid();
  427.     i=0;
  428.     while(1) {
  429.         if((fscanf(list,"%d %lf %ld",
  430.             &score[i].uid,
  431.             &score[i].amt,
  432.             &score[i].ngames))
  433.         == EOF) break;
  434.         while((c=fgetc(list))==' ') ;
  435.         nchars=0;
  436.         while(c!='\n' && nchars<NAMELEN) {
  437.             score[i].name[nchars++]=c;
  438.             c=fgetc(list);
  439.         }
  440.         while(c!='\n') c=fgetc(list);
  441.         score[i].name[nchars]=0;
  442.         if(score[i].uid==cuid) {
  443.             score[i].amt = score[i].amt + (wins-loss);
  444.             score[i].ngames = score[i].ngames + 1;
  445.             did=1;
  446.         }
  447.         i++;
  448.     }
  449.     fclose(list);
  450.     if(!did) {
  451.         score[n].uid = cuid;
  452.         score[n].amt = (wins-loss);
  453.         score[n].ngames = 1;
  454.         if(getenv("CRAPSNAME")==NULL)
  455. #ifdef    SYSV
  456.             strncpy(score[n].name,getenv("LOGNAME"),NAMELEN);
  457. #else
  458. #ifdef  XENIX
  459.             strncpy(score[n].name,getenv("LOGNAME"),NAMELEN);
  460. #else
  461.             strncpy(score[n].name,getenv("USER"),NAMELEN);
  462. #endif
  463. #endif
  464.         else strncpy(score[n].name,getenv("CRAPSNAME"),NAMELEN);
  465.         n++;
  466.     }
  467.     qsort(score,n,sizeof(scores),comp);
  468.     list=fopen(sfile,"w");
  469.     for(i=0;i<n;i++)
  470.         fprintf(list,"%d %.2f %ld %s\n",
  471.         score[i].uid,
  472.         score[i].amt,
  473.         score[i].ngames,
  474.         score[i].name);
  475.     fclose(list);
  476.     clear();
  477.     mvaddstr(0,10,"Name                Total to Date              Games");
  478.     mvaddstr(1,10,"----------------------------------------------------");
  479.     refresh();
  480.     putchar('\n');
  481.     for(i=0;i<n;i++)
  482.         printf("          %-28s%10.2f%14ld\n",score[i].name,score[i].amt,score[i].ngames);
  483.     myexit();
  484. #endif
  485.     return(0);
  486. }
  487.  
  488. #ifdef    SCORES
  489. comp(x,y)
  490. scores *x,*y;
  491. {
  492.     if(x->amt > y->amt) return(-1);
  493.     if(x->amt == y->amt) return(0);
  494.     return(1);
  495. }
  496. #endif
  497.  
  498. myexit()
  499. {
  500.     unlink(reclock);
  501. }
  502. SHAR_EOF
  503. fi # end of overwriting check
  504. if test -f 'help.c'
  505. then
  506.     echo shar: will not over-write existing file "'help.c'"
  507. else
  508. cat << \SHAR_EOF > 'help.c'
  509. #include "types.h"
  510. #include "ext.h"
  511.  
  512. help()
  513. {
  514.     clear(); refresh();
  515.     mvaddstr(0 ,20,"Key        Action");
  516.     mvaddstr(1 ,20,"---        ------");
  517.     mvaddstr(2, 20," r         Roll the Dice");
  518.     mvaddstr(3 ,20," p         Pass Line bet");
  519.     mvaddstr(4 ,20," d         Dont Pass bet");
  520.     mvaddstr(5 ,20," c         Come bet");
  521.     mvaddstr(6 ,20," D         Dont Come bet");
  522.     mvaddstr(7 ,20," o         Take odds on Pass Line/Come bets");
  523.     mvaddstr(8 ,20," l         Lay odds on Dont Pass/Dont Come bets");
  524.     mvaddstr(9 ,20," b         Place bet");
  525.     mvaddstr(10,20," f         Field bet");
  526.     mvaddstr(11,20," h         Hardway bet");
  527.     mvaddstr(12,20," s         Any Seven bet");
  528.     mvaddstr(13,20," a         Any Craps bet");
  529.     mvaddstr(14,20," 2         Snake Eyes (two) bet");
  530.     mvaddstr(15,20," 3         Three bet");
  531.     mvaddstr(16,20," y         Eeyo-'Leven (Eleven) bet");
  532.     mvaddstr(17,20," u         Boxcars (Twelve) bet");
  533.     mvaddstr(18,20," q         Quit");
  534.     mvaddstr(19,20," ?         This List");
  535.     mvaddstr(20,20," !         Shell escape");
  536.     mvaddstr(21,20,"^L         Redraw the screen");
  537.     refresh();
  538.     msg("Press [space] to continue",23,1);
  539.     print_board();
  540.     if(point) mvaddstr(4,pcol[point],"----");
  541.     pr_bets();
  542.     cheat=1;
  543.     roll();
  544.     cheat=0;
  545.     update(1);
  546. }
  547. SHAR_EOF
  548. fi # end of overwriting check
  549. if test -f 'main.c'
  550. then
  551.     echo shar: will not over-write existing file "'main.c'"
  552. else
  553. cat << \SHAR_EOF > 'main.c'
  554. /*
  555.  *  I hearby put this program in the Public Domain.  It can be used
  556.  *  in any way, shape or form.
  557.  *
  558.  *  I assume no responsibility for anything this program may procure
  559.  *  (or not procure) on those who use it. :-)
  560.  *
  561.  *  Ray Tripamer,
  562.  *  Unviersity of Nevada, Las Vegas (Yes, that says Las Vegas!)
  563.  *
  564.  */
  565. #include "types.h"
  566.  
  567. int pcol[11] = {0,0,0,0,C+11,C+19,C+27,0,C+35,C+43,C+51};
  568.  
  569. char *keys="pcdDofblhsa23yuCq?!r ",line[81];
  570. char *nums[] = {
  571.     "","","Two","Three","Four","Five","Six","Seven","Eight","Nine",
  572.     "Ten","Eleven","Twelve"
  573. };
  574. char *Bets[] = {
  575.     "pass line:", "come:", "don't pass:", "don't come:",
  576.     "take odds:", "field:", "place:","lay odds:", "hard way:",
  577.     "any seven:", "any craps:", "snake eyes:", "ace-duece:",
  578.     "eleven:", "boxcars:"
  579. };
  580.  
  581. double total, wins, loss, otot, olos, owin, handle;
  582.  
  583. double pass,comeb,come[11],odds[11];
  584. double dont,dcomeb,dcome[11],lodds[11];
  585. double place[11],field;
  586. double hways[11],aseven,acraps,eeyo,boxcars,aces,aceduece;
  587.  
  588. int dice[2]={3,4},sum,point,cheat;
  589. int plcpays[11][2] = {    {0,0},{0,0},{0,0},{0,0},
  590.             {9,5},{7,5},{7,6},{0,0},
  591.             {7,6},{7,5},{9,5} };
  592. int op[11][2] ={    {0,0},{0,0},{0,0},{0,0},
  593.             {2,1},{3,2},{6,5},{0,0},
  594.             {6,5},{3,2},{2,1} };
  595. int hp[11][2] = {    {0,0},{0,0},{0,0},{0,0},
  596.             {7,1},{0,0},{9,1},{0,0},
  597.             {9,1},{0,0},{7,1} };
  598. int fpays[13] = {0,0,2,1,1,0,0,0,0,1,1,1,3};
  599.  
  600. long numbets=0;
  601.  
  602. main()
  603. {
  604.     int stop(), i;
  605.  
  606.     signal(SIGINT,stop);
  607.     initscr();
  608.     noecho();
  609.     crmode();
  610.     seedrand();
  611.     total=100.0;
  612.     otot=owin=olos=handle=0.0;
  613.     loss=wins=pass=dont=dcomeb=comeb=0.0;
  614.     aseven=acraps=aceduece=boxcars=aces=eeyo=0.0;
  615.     for(i=0;i<11;i++) dcome[i]=come[i]=odds[i]=place[i]=hways[i]=0.0;
  616.     print_board();
  617.     update(1);
  618.     cheat=1;
  619.     roll();
  620.     while(1) {
  621.         make_bets();
  622.         roll();
  623.         pay_winners();
  624.     }
  625. }
  626.  
  627. stop()
  628. {
  629.     final();
  630.     move(23,0); clrtoeol(); refresh();
  631.     echo();
  632.     nocrmode();
  633.     endwin();
  634.     exit(0);
  635. }
  636. SHAR_EOF
  637. fi # end of overwriting check
  638. if test -f 'makeb.c'
  639. then
  640.     echo shar: will not over-write existing file "'makeb.c'"
  641. else
  642. cat << \SHAR_EOF > 'makeb.c'
  643. #include "types.h"
  644. #include "ext.h"
  645.  
  646. make_bets()
  647. {
  648.     int i,fk,bad,y,z;
  649.     static int fl=0;
  650.     double getbet(),x,t;
  651.     char c, *shell = "/bin/csh",*cp="AahLyRUTKrVsc",pp[15];
  652.  
  653.     pr_bets();
  654.     cheat=0;
  655.     while(1) {
  656.         if((z=zippo())==1) {
  657.             announce(0);
  658.             announce("Sorry, but you are FLAT BROKE! ~");
  659.             announce("Now BEAT IT!! ~");
  660.             pr_an();
  661.             stop();
  662.         } else if(z==2 && !fl) {
  663.             announce(0);
  664.             announce("You have no money in your rack, ~");
  665.             announce("but you still have bets working. ~");
  666.             fl=1;
  667.             pr_an();
  668.             continue;
  669.         }
  670.         addline(0);
  671.         addline("Bet:");
  672.         c=getchar();
  673.         if((i=ind(keys,c))== -1) {
  674.             BEEP;
  675.             continue;
  676.         } else {
  677.             switch(i) {
  678.                 case ROLL:
  679.                     break;
  680.                 case HELP:
  681.                     help();
  682.                     continue;
  683.                 case SHELL:
  684.                     clear(); move(23,1); refresh();
  685.                     echo(); nocrmode();
  686.                     fk=fork();
  687.                     if (fk==0) {
  688.                         setuid(getuid());
  689.                         execl(shell,shell,0);
  690.                     } else wait(0);
  691.                     noecho(); crmode();
  692.                     clear(); 
  693.                     print_board();
  694.                     if(point)
  695.                         mvaddstr(4,pcol[point],"----");
  696.                     pr_bets();
  697.                     update(1);
  698.                     cheat=1;
  699.                     roll();
  700.                     cheat=0;
  701.                     continue;
  702.                 case QUIT:
  703.                     stop();
  704.                 case REFRESH:
  705.                     wrefresh(curscr);
  706.                     continue;
  707.                 case CHEAT:
  708.                     addline("Enter password:");
  709.                     gs(pp,15);
  710.                     if(strcmp(crypt(pp,"Aa"),cp)) {
  711.                         BEEP;
  712.                         continue;
  713.                     }
  714.                     cheat=1;
  715.                     addline("first die?");
  716.                     dice[0]=(int)getbet(1);
  717.                     if(dice[0]==-1||dice[0]>6) continue;
  718.                     addline("second die?");
  719.                     dice[1]=(int)getbet(1);
  720.                     if(dice[1]==-1||dice[1]>6) continue;
  721.                     continue;
  722.                 case FIELD:
  723.                     if(mbet(i,&field)==ESC) continue;
  724.                     pr_bets();
  725.                     update(0);
  726.                     continue;
  727.                 case ASEVEN:
  728.                     if(mbet(i,&aseven)==ESC) continue;
  729.                     pr_bets();
  730.                     update(0);
  731.                     continue;
  732.                 case EEYO:
  733.                     if(mbet(i,&eeyo)==ESC) continue;
  734.                     pr_bets();
  735.                     update(0);
  736.                     continue;
  737.                 case TWELVE:
  738.                     if(mbet(i,&boxcars)==ESC) continue;
  739.                     pr_bets();
  740.                     update(0);
  741.                     continue;
  742.                 case TWO:
  743.                     if(mbet(i,&aces)==ESC) continue;
  744.                     pr_bets();
  745.                     update(0);
  746.                     continue;
  747.                 case THREE:
  748.                     if(mbet(i,&aceduece)==ESC) continue;
  749.                     pr_bets();
  750.                     update(0);
  751.                     continue;
  752.                 case ACRAPS:
  753.                     if(mbet(i,&acraps)==ESC) continue;
  754.                     pr_bets();
  755.                     update(0);
  756.                     continue;
  757.                 case HWAY:
  758.                     do {
  759.                         addline(0);
  760.                         addline(Bets[i]);
  761.                         addline(" number?");
  762.                         y=(int)getbet(1);
  763.                         if(y==-1) break;
  764.                     } while(!chk_hrd(y));
  765.                     if(y==-1) continue;
  766.                     t=hways[y];
  767.                     if(mbet(i,&t)==ESC) continue;
  768.                     hways[y]=t;
  769.                     pr_bets();
  770.                     update(0);
  771.                     continue;
  772.                 case DONT:
  773.                     if(point) msg("The point is already established. Try a dont come bet",23,1);
  774.                     else if(mbet(i,&dont)==ESC) continue;
  775.                     pr_bets();
  776.                     update(0);
  777.                     continue;
  778.                 case DCOME:
  779.                     if(!point)
  780.                         msg("There is no point yet.  Bet on the Dont Pass Line.",23,1);
  781.                     else if(mbet(i,&dcomeb)==ESC) continue;
  782.                     pr_bets();
  783.                     update(0);
  784.                     continue;
  785.                 case LODDS:
  786.                     do {
  787.                         addline(0);
  788.                         addline(Bets[i]);
  789.                         addline(" number?");
  790.                         y=(int)getbet(1);
  791.                         if(y==-1) break;
  792.                     } while((!chk_plc(y)) ||(d_or_p(y)));
  793.                     if(y==-1) continue;
  794.                     t=lodds[y];
  795.                     if(mbet(i,&t)==ESC) continue;
  796.                     lodds[y]=t;
  797.                     pr_bets();
  798.                     update(0);
  799.                     continue;
  800.                 case PASS:
  801.                     if(point) msg("The point is already established. Try a come bet.",23,1);
  802.                     else if(mbet(i,&pass)==ESC) continue;
  803.                     pr_bets();
  804.                     update(0);
  805.                     continue;
  806.                 case COME:
  807.                     if(!point)
  808.                         msg("There is no point yet.  Bet on the Pass Line.",23,1);
  809.                     else if(mbet(i,&comeb)==ESC) continue;
  810.                     pr_bets();
  811.                     update(0);
  812.                     continue;
  813.                 case ODDS:
  814.                     do {
  815.                         addline(0);
  816.                         addline(Bets[i]);
  817.                         addline(" number?");
  818.                         y=(int)getbet(1);
  819.                         if(y==-1) break;
  820.                     } while((!chk_plc(y)) ||(c_or_p(y)));
  821.                     if(y==-1) continue;
  822.                     t=odds[y];
  823.                     if(mbet(i,&t)==ESC) continue;
  824.                     odds[y]=t;
  825.                     pr_bets();
  826.                     update(0);
  827.                     continue;
  828.                 case PLACE:
  829.                     do {
  830.                         addline(0);
  831.                         addline(Bets[i]);
  832.                         addline(" number?");
  833.                         y=(int)getbet(1);
  834.                         if(y==-1) break;
  835.                     } while(!chk_plc(y));
  836.                     if(y==-1) continue;
  837.                     t=place[y];
  838.                     if(mbet(i,&t)==ESC) continue;
  839.                     place[y]=t;
  840.                     pr_bets();
  841.                     update(0);
  842.                     continue;
  843.             }
  844.             refresh();
  845.             break;
  846.         }
  847.     }
  848. }
  849.  
  850. zippo()
  851. {
  852.     double s;
  853.     int i;
  854.  
  855.     if(total==0.0) {
  856.         s=pass+odds[point]+dont+lodds[point];
  857.         s=s+aseven+eeyo+boxcars+aces+aceduece+acraps;
  858.         s=s+comeb+dcomeb+field;
  859.         for(i=0;i<11;i++) {
  860.             if(i!=point) {s=s+odds[i];s=s+lodds[i];}
  861.             s=s+place[i]+dcome[i]+come[i]+hways[i];
  862.         }
  863.         if(s!=0.0) return(2);
  864.         else return(1);
  865.     } else return(0);
  866. }
  867.  
  868. mbet(i,x)
  869. int i;
  870. double *x;
  871. {
  872.     int bad=0;
  873.     double t=0.0;
  874.  
  875.     do {
  876.         if(bad) BEEP;
  877.         bad=0;
  878.         do {
  879.             if(t>LIMIT) BEEP;
  880.             addline(0);
  881.             addline(Bets[i]);
  882.             addline(" how much ? $");
  883.             if((t=getbet(1))== -1.0) return(ESC);
  884.         } while(t>LIMIT);
  885.         total += *x;
  886.         *x = t;
  887.         total -= *x;
  888.         if(t!=0.0) {numbets=numbets+1; handle=handle+t;}
  889.         if(total <0.0) {
  890.             bad=1;
  891.             total += *x;
  892.             *x = 0.0;
  893.             if(t!=0.0) {numbets=numbets-1; handle=handle-t;}
  894.         }
  895.     } while(bad);
  896.     return(1);
  897. }
  898.  
  899. gs(s,n)
  900. char *s;
  901. int n;
  902. {
  903.     char c;
  904.  
  905.     while(1) {
  906.         c=getchar();
  907.         if(c=='\n'||c==EOF) break;
  908.         if(n) {
  909.             --n;
  910.             *s++=c;
  911.         }
  912.     }
  913.     *s=0;
  914. }
  915. SHAR_EOF
  916. fi # end of overwriting check
  917. if test -f 'pass.c'
  918. then
  919.     echo shar: will not over-write existing file "'pass.c'"
  920. else
  921. cat << \SHAR_EOF > 'pass.c'
  922. #include "types.h"
  923. #include "ext.h"
  924.  
  925. double bet(x,n,d)
  926. double x;
  927. int n,d;
  928. {
  929.     int dollars=(int)x,quarters;
  930.  
  931.     if(n==0 || d==0 || x==(double)0.0) return(0.0);
  932.     quarters=(int)((x-(double)dollars)/.25)+((dollars%d)*4);
  933.     dollars -= (dollars%d);
  934.     return((double)(((dollars/d*n)+(dollars%d))) +
  935.            (double)(((quarters/d)*n*.25)+((double)(quarters%d)*.25)));
  936. }
  937.  
  938. ppassln()    /* pay the pass line */
  939. {
  940.     double bet(),x;
  941.  
  942.     x=pass+bet(odds[point],op[point][0],op[point][1]);
  943.     total=total+x+odds[point];
  944.     wins=wins+x;
  945.     if(pass!=0.0) {
  946.         sprintf(line,"You won %.2f on the Pass Line! ~",x);
  947.         announce(line);
  948.     }
  949.     odds[point]=0.0;
  950. }
  951.  
  952. cpassln()    /* clear the pass line */
  953. {
  954.     loss=loss+pass+odds[point];
  955.     if(pass!=0.0) announce("Line Away! ~");
  956.     pass=0.0;
  957.     odds[point]=0.0;
  958. }
  959.  
  960. pcomeb(on)    /* pay the come bar */
  961. {
  962.     total=total+comeb;
  963.     wins=wins+comeb;
  964.     if(comeb!=0.0) announce("You won your Come Bar Bet! ~");
  965.     if(on) {
  966.         total=total+comeb;
  967.         if(comeb!=0.0) announce("Your Come Bet is back. ~");
  968.         comeb=0.0;
  969.     }
  970. }
  971.  
  972. ccomeb()    /* clear the come bar */
  973. {
  974.     loss=loss+comeb;
  975.     if(comeb!=0.0) announce("You lost your Come Bar Bet! ~");
  976.     comeb=0.0;
  977. }
  978.  
  979. ccome(off)    /* clear the come points */
  980. int off;
  981. {
  982.     int i,j=0;
  983.  
  984.     for(i=0;i<11;i++) {
  985.         loss=loss+come[i];
  986.         if(come[i]!=0.0) j++;
  987.         if(off) total=total+odds[i];
  988.         else loss=loss+odds[i];
  989.         come[i]=odds[i]=0.0;
  990.     }
  991.     sprintf(line,"Your come %s lost! ~",(j==1) ? "bet":"bets all");
  992.     if(j) announce(line);
  993.     if(off && j) announce("But you got your odds back! ~");
  994. }
  995.  
  996. do_come(n,on)
  997. int n,on;
  998. {
  999.     double bet(), x;
  1000.  
  1001.     x=come[n];
  1002.     if(on) x = x + bet(odds[n],op[n][0],op[n][1]);
  1003.     if(come[n]!=0.0 && comeb!=0.0) {
  1004.         if(come[n]==comeb) {
  1005.             total=total+x;
  1006.             wins=wins+x;
  1007.             sprintf(line,"Off and On on the %d for %.2f. ~",n,x);
  1008.             announce(line);
  1009.         } else {
  1010.             total=total+x+come[n]+odds[n];
  1011.             wins=wins+x;
  1012.             sprintf(line,"You won %.2f on your Come Bet! ~",x);
  1013.             announce(line);
  1014.             announce("You got your come bet");
  1015.             if(odds[n]!=0.0) announce("/odds");
  1016.             announce(" back. ~");
  1017.             come[n]=odds[n]=0.0;
  1018.             come[n]=comeb;
  1019.             comeb=0.0;
  1020.             sprintf(line,"Your come bet got moved to the %d. ~",n);
  1021.             announce(line);
  1022.         }
  1023.     } else if(come[n]!=0.0 && comeb==0.0) {
  1024.         total=total+x+come[n]+odds[n];
  1025.         wins=wins+x;
  1026.         sprintf(line,"You won %.2f on your Come Bet! ~",x);
  1027.         announce(line);
  1028.         if(!on) announce("But your odds were off! ~");
  1029.         come[n]=odds[n]=0.0;
  1030.     } else if(comeb!=0.0) {
  1031.         come[n]=comeb;
  1032.         comeb=0.0;
  1033.         sprintf(line,"Your come bet got moved to the %d. ~",n);
  1034.         announce(line);
  1035.     }
  1036. }
  1037. SHAR_EOF
  1038. fi # end of overwriting check
  1039. if test -f 'pay.c'
  1040. then
  1041.     echo shar: will not over-write existing file "'pay.c'"
  1042. else
  1043. cat << \SHAR_EOF > 'pay.c'
  1044. #include "types.h"
  1045. #include "ext.h"
  1046.  
  1047. pay_winners()
  1048. {
  1049.     int clrp=0,mark=0;
  1050.  
  1051.     if(sum==7) {
  1052.         if(!point) {
  1053.             announce("Seven, A Natural! ~");
  1054.             ppassln();
  1055.             cdontln();
  1056.             ccome(1);
  1057.             pdonts();
  1058.         } else {
  1059.             announce("Seven out! ~");
  1060.             announce(line);
  1061.             cpassln();
  1062.             cplace();
  1063.             ccome(0);
  1064.             cdontb();
  1065.             pcomeb(1);
  1066.             pdontln();
  1067.             pdonts();
  1068.             do_dont(sum);
  1069.             clrp=1;
  1070.         }
  1071.     } else if(sum==11) {
  1072.         announce("Eee-yo 'LEVEN! ~");
  1073.         if(!point) {
  1074.             ppassln();
  1075.             cdontln();
  1076.         } else {
  1077.             pcomeb(0);
  1078.             cdontb();
  1079.         }
  1080.     } else if(sum==2 || sum==3 || sum==12) {
  1081.         announce("Craps! ");
  1082.         if(sum==2) announce(" - aces! ~");
  1083.         else if(sum==3) announce(" - ace-duece! ~");
  1084.         else announce(" - sixes! ~");
  1085.         if(!point) {
  1086.             cpassln();
  1087.             if(sum!=12) pdontln();
  1088.             else bar_the_12();
  1089.         } else {
  1090.             ccomeb();
  1091.             if(sum!=12) pdontb();
  1092.             else bar_the_12();
  1093.         }
  1094.     } else {
  1095.         sprintf(line,"%s!",nums[sum]);
  1096.         if(dice[1]==dice[0]) strcat(line,", The Hardway!");
  1097.         strcat(line," ~");
  1098.         announce(line);
  1099.         if(sum==point) {
  1100.             ppassln();
  1101.             pplace(sum);
  1102.             cdontln();
  1103.             do_dont(sum);
  1104.             clrp=1;
  1105.             do_come(sum,1);
  1106.         } else {
  1107.             if(point) pplace(sum);
  1108.             else mark=1;
  1109.             csdont(sum,0);
  1110.             do_dont(sum);
  1111.             do_come(sum,(point!=0));
  1112.         }
  1113.     }
  1114.     pfield();
  1115.     props(sum);
  1116.     if(clrp) cl_point();
  1117.     if(mark) mark_point(sum);
  1118.     pr_an();
  1119.     update(0);
  1120. }
  1121. SHAR_EOF
  1122. fi # end of overwriting check
  1123. if test -f 'prints.c'
  1124. then
  1125.     echo shar: will not over-write existing file "'prints.c'"
  1126. else
  1127. cat << \SHAR_EOF > 'prints.c'
  1128. #include "types.h"
  1129. #include "ext.h"
  1130.  
  1131. pr_bets()
  1132. {
  1133.     int i;
  1134.  
  1135.     mvaddstr(R+15,C+40,"       ");    /* clear pass line */
  1136.     mvaddstr(R+13,C+40,"       ");    /* clear dont pass */
  1137.     mvaddstr(R+15,C+47,"        ");    /* clear pass line odds */
  1138.     mvaddstr(R+13,C+47,"        "); /* clear dont pass odds */
  1139.     mvaddstr(R+11,C+48,"       ");    /* clear field */
  1140.     mvaddstr(R+8 ,C+48,"       ");     /* clear come bar */
  1141.     mvaddstr(R+6 ,C+2 ,"       ");    /* clear dont come bar */
  1142.     mvaddstr(R+2 ,D+5 ,"       ");    /* clear any seven */
  1143.     mvaddstr(R+6 ,D+1 ,"       ");    /* clear hard 6 */
  1144.     mvaddstr(R+6 ,D+9 ,"       ");    /* clear hard 10 */
  1145.     mvaddstr(R+10,D+1 ,"       ");    /* clear hard 8 */
  1146.     mvaddstr(R+10,D+9 ,"       ");    /* clear hard 4 */
  1147.     mvaddstr(R+14,D+1 ,"       ");  /* clear eleven */
  1148.     mvaddstr(R+14,D+9 ,"       ");    /* clear twelve */
  1149.     mvaddstr(R+18,D+1 ,"       ");    /* clear snake eyes */
  1150.     mvaddstr(R+18,D+9 ,"       ");    /* clear ace-duece */
  1151.     mvaddstr(R+21,D+5 ,"       ");    /* clear any craps */
  1152.     for(i=0;i<11;i++) {
  1153.         if(chk_plc(i)) {
  1154.             mvaddstr(R+7,pcol[i]-1,"-------"); /* place bets */
  1155.             mvaddstr(R+6,pcol[i]-1,"       "); /* come bet */
  1156.             mvaddstr(R+5,pcol[i]-1,"       "); /* come bet odds */
  1157.             mvaddstr(R+1,pcol[i]-1,"       "); /* done come bet */
  1158.             mvaddstr(R  ,pcol[i]-1,"-------"); /* dont come odds */
  1159.         }
  1160.     }
  1161.     if(pass!=0.0) {move(R+15,C+40); printw("$%.2f",pass);}
  1162.     if(dont!=0.0) {move(R+13,C+40); printw("$%.2f",dont);}
  1163.     if(point && odds[point]!=0.0) {
  1164.         move(R+15,C+47); printw("/$%.2f",odds[point]);
  1165.     }
  1166.     if(point && lodds[point]!=0.0) {
  1167.         move(R+13,C+47); printw("/$%.2f",lodds[point]);
  1168.     }
  1169.     if(field!=0.0) {move(R+11,C+48); printw("$%.2f",field);}
  1170.     if(comeb!=0.0) {move(R+8,C+48); printw("$%.2f",comeb);}
  1171.     if(dcomeb!=0.0) {move(R+6,C+2); printw("$%.2f",dcomeb);}
  1172.     if(aseven!=0.0) {move(R+2,D+5); printw("$%.2f",aseven);}
  1173.     if(hways[6]!=0.0) {move(R+6,D+1); printw("$%.2f",hways[6]);}
  1174.     if(hways[10]!=0.0) {move(R+6,D+9); printw("$%.2f",hways[10]);}
  1175.     if(hways[8]!=0.0) {move(R+10,D+1); printw("$%.2f",hways[8]);}
  1176.     if(hways[4]!=0.0) {move(R+10,D+9); printw("$%.2f",hways[4]);}
  1177.     if(eeyo!=0.0) {move(R+14,D+1); printw("$%.2f",eeyo);}
  1178.     if(boxcars!=0.0) {move(R+14,D+9); printw("$%.2f",boxcars);}
  1179.     if(aces!=0.0) {move(R+18,D+1); printw("$%.2f",aces);}
  1180.     if(aceduece!=0.0) {move(R+18,D+9); printw("$%.2f",aceduece);}
  1181.     if(acraps!=0.0) {move(R+21,D+5); printw("$%.2f",acraps);}
  1182.     for(i=0;i<11;i++) {
  1183.         if(place[i]!=0.0 && chk_plc(i)) {
  1184.             move(R+7,pcol[i]-1);
  1185.             printw("$%.2f",place[i]);
  1186.         }
  1187.         if(come[i]!=0.0 && chk_plc(i)) {
  1188.             move(R+6,pcol[i]-1);
  1189.             printw("$%.2f",come[i]);
  1190.             if(odds[i]!=0.0) {
  1191.                 move(R+5,pcol[i]-1);
  1192.                 printw("$%.2f",odds[i]);
  1193.             }
  1194.         }
  1195.         if(dcome[i]!=0.0 && chk_plc(i)) {
  1196.             move(R+1,pcol[i]-1);
  1197.             printw("$%.2f",dcome[i]);
  1198.             if(lodds[i]!=0.0) {
  1199.                 move(R,pcol[i]-1);
  1200.                 printw("$%.2f",lodds[i]);
  1201.             }
  1202.         }
  1203.     }
  1204.     refresh();
  1205. }
  1206.  
  1207. print_board()
  1208. {
  1209.  
  1210.     clear();
  1211. mvaddstr(R   ,C,"----------------------------------------------------------");
  1212. mvaddstr(R+1 ,C,"|        |       |       |       |       |       |       |");
  1213. mvaddstr(R+2 ,C,"|  DONT  -------------------------------------------------");
  1214. mvaddstr(R+3 ,C,"|  COME  |   4   |   5   |   6   |   8   |   9   |  10   |");
  1215. mvaddstr(R+4 ,C,"|        |       |       |       |       |       |       |");
  1216. mvaddstr(R+5 ,C,"| BAR 12 |       |       |       |       |       |       |");
  1217. mvaddstr(R+6 ,C,"|        |       |       |       |       |       |       |");
  1218. mvaddstr(R+7 ,C,"----------------------------------------------------------");
  1219. mvaddstr(R+8 ,C,"|                            C O M E                     |");
  1220. mvaddstr(R+9 ,C,"----------------------------------------------------------");
  1221. mvaddstr(R+10,C,"         |   double     F I E L D      triple            |");
  1222. mvaddstr(R+11,C,"         |     2    3   4   9  10  11    12              |");
  1223. mvaddstr(R+12,C,"         -------------------------------------------------");
  1224. mvaddstr(R+13,C,"         |        DONT PASS BAR 12                       |");
  1225. mvaddstr(R+14,C,"         -------------------------------------------------");
  1226. mvaddstr(R+15,C,"         |        P A S S    L I N E                     |");
  1227. mvaddstr(R+16,C,"         -------------------------------------------------");
  1228. refresh();
  1229. mvaddstr(R   ,D,"-----------------");
  1230. mvaddstr(R+1 ,D,"| Any Seven 4-1 |");
  1231. mvaddstr(R+2 ,D,"|               |");
  1232. mvaddstr(R+3 ,D,"-----------------");
  1233. mvaddstr(R+4 ,D,"|Hard 6 |Hard 10|");
  1234. mvaddstr(R+5 ,D,"|  9-1  |  7-1  |");
  1235. mvaddstr(R+6 ,D,"|       |       |");
  1236. mvaddstr(R+7 ,D,"-----------------");
  1237. mvaddstr(R+8 ,D,"|Hard 8 |Hard 4 |");
  1238. mvaddstr(R+9 ,D,"|  9-1  |  7-1  |");
  1239. mvaddstr(R+10,D,"|       |       |");
  1240. mvaddstr(R+11,D,"-----------------");
  1241. mvaddstr(R+12,D,"|Eleven |Twelve |");
  1242. mvaddstr(R+13,D,"| 14-1  | 29-1  |");
  1243. mvaddstr(R+14,D,"|       |       |");
  1244. mvaddstr(R+15,D,"-----------------");
  1245. mvaddstr(R+16,D,"|  Two  | Three |");
  1246. mvaddstr(R+17,D,"| 29-1  |  14-1 |");
  1247. mvaddstr(R+18,D,"|       |       |");
  1248. mvaddstr(R+19,D,"-----------------");
  1249. mvaddstr(R+20,D,"| Any Craps 8-1 |");
  1250. mvaddstr(R+21,D,"|               |");
  1251. mvaddstr(R+22,D,"-----------------");
  1252. }
  1253. SHAR_EOF
  1254. fi # end of overwriting check
  1255. if test -f 'props.c'
  1256. then
  1257.     echo shar: will not over-write existing file "'props.c'"
  1258. else
  1259. cat << \SHAR_EOF > 'props.c'
  1260. #include "types.h"
  1261. #include "ext.h"
  1262.  
  1263. props(n)        /* do the proposition bets */
  1264. int n;
  1265. {
  1266.     int i,j=0,affect;
  1267.     double x,bet();
  1268.  
  1269.     if(aseven!=0.0)
  1270.         if(n==7) {
  1271.             x=bet(aseven,4,1);
  1272.             total=total+x;
  1273.             wins=wins+x;
  1274.             sprintf(line,"You won $%.2f on your Any Seven! ~",x);
  1275.             announce(line);
  1276.         } else {
  1277.             loss=loss+aseven;
  1278.             announce("Any Seven Bet Lost! ~");
  1279.             aseven=0.0;
  1280.         }
  1281.     if(acraps!=0.0)
  1282.         if(n==2||n==3||n==12) {
  1283.             x=bet(acraps,8,1);
  1284.             total=total+x;
  1285.             wins=wins+x;
  1286.             sprintf(line,"You won $%.2f on Any Craps! ~",x);
  1287.             announce(line);
  1288.         } else {
  1289.             loss=loss+acraps;
  1290.             announce("Any Craps Bet Lost! ~");
  1291.             acraps=0.0;
  1292.         }
  1293.     if(eeyo!=0.0)
  1294.         if(n==11) {
  1295.             x=bet(eeyo,14,1);
  1296.             total=total+x;
  1297.             wins=wins+x;
  1298.             sprintf(line,"You won $%.2f on Eleven! ~",x);
  1299.             announce(line);
  1300.         } else {
  1301.             loss=loss+eeyo;
  1302.             announce("Eleven Bet Lost! ~");
  1303.             eeyo=0.0;
  1304.         }
  1305.     if(boxcars!=0.0)
  1306.         if(n==12) {
  1307.             x=bet(boxcars,29,1);
  1308.             total=total+x;
  1309.             wins=wins+x;
  1310.             sprintf(line,"You won $%.2f on Boxcars! ~",x);
  1311.             announce(line);
  1312.         } else {
  1313.             loss=loss+boxcars;
  1314.             announce("Boxcars Bet Lost! ~");
  1315.             boxcars=0.0;
  1316.         }
  1317.     if(aces!=0.0)
  1318.         if(n==2) {
  1319.             x=bet(aces,29,1);
  1320.             total=total+x;
  1321.             wins=wins+x;
  1322.             sprintf(line,"You won $%.2f on Snake Eyes! ~",x);
  1323.             announce(line);
  1324.         } else {
  1325.             loss=loss+aces;
  1326.             announce("Snake Eyes Bet Lost! ~");
  1327.             aces=0.0;
  1328.         }
  1329.     if(aceduece!=0.0)
  1330.         if(n==3) {
  1331.             x=bet(aceduece,14,1);
  1332.             total=total+x;
  1333.             wins=wins+x;
  1334.             sprintf(line,"You won $%.2f on Threee Bet! ~",x);
  1335.             announce(line);
  1336.         } else {
  1337.             loss=loss+aceduece;
  1338.             announce("Three Bet Lost! ~");
  1339.             aceduece=0.0;
  1340.         }
  1341.     for(affect=0,i=0;i<11;i++) {
  1342.         if(hways[i]!=0.0) j++;
  1343.         if(hways[i]!=0.0 && n==7)
  1344.             if(point) {loss=loss+hways[i]; hways[i]=0.0;}
  1345.             else affect=1;
  1346.         if(hways[i]!=0.0 && n==i && dice[0]==dice[1])
  1347.             if(point) {
  1348.                 if(i==4||i==10) x=bet(hways[i],7,1);
  1349.                 else x=bet(hways[i],9,1);
  1350.                 total=total+x;
  1351.                 wins=wins+x;
  1352.                 sprintf(line,"You won $%.2f on the Hard %s.~",x,nums[i]);
  1353.                 announce(line);
  1354.             } else affect=1;
  1355.         if(hways[i]!=0.0 && n==i && dice[0]!=dice[1])
  1356.             if(point) {
  1357.                 loss=loss+hways[i];
  1358.                 hways[i]=0.0;
  1359.                 sprintf(line,"Hard %s Down! ~",nums[i]);
  1360.                 announce(line);
  1361.             } else affect=1;
  1362.     }
  1363.     sprintf(line,"Hardway Bet%sDown! ~",(j==1)?" ":"s ");
  1364.     if(n==7 && j && point) announce(line);
  1365.     if(j && !point && affect) announce("Hardways off on the Comeout! ~");
  1366. }
  1367. SHAR_EOF
  1368. fi # end of overwriting check
  1369. if test -f 'random.c'
  1370. then
  1371.     echo shar: will not over-write existing file "'random.c'"
  1372. else
  1373. cat << \SHAR_EOF > 'random.c'
  1374. #include "types.h"
  1375. #include "ext.h"
  1376. #ifdef    BSD42
  1377. #include <sys/time.h>
  1378. #endif
  1379.  
  1380. /*
  1381.  * seed the random number generator
  1382.  *
  1383.  */
  1384. seedrand()
  1385. {
  1386. #ifdef BSD42
  1387.     struct timeval tp;
  1388.     struct timezone tpz;
  1389.  
  1390.     gettimeofday(&tp,&tpz);
  1391.     srandom((int)tp.tv_sec);
  1392. #endif
  1393. #ifdef BSD29
  1394.     randomize();
  1395. #endif
  1396. #ifdef SYSV
  1397.     long seed;
  1398.     long time();
  1399.     void srand48();
  1400.  
  1401.     time(&seed);
  1402.     srand48(seed);
  1403. #endif
  1404. #ifdef XENIX
  1405.     long seed;
  1406.     long time();
  1407.  
  1408.     time(&seed);
  1409.     srand(seed);
  1410. #endif
  1411. }
  1412.  
  1413. /*
  1414.  * get_rand - return a random number 1-6
  1415.  *
  1416.  */
  1417. get_rand()
  1418. {
  1419. #ifdef BSD42
  1420.     long random();
  1421.     return( (int) random() % 6 + 1);
  1422. #endif
  1423. #ifdef BSD29
  1424.     double ranm();
  1425.     return( (int) (ranm() * 6.0) + 1.0);
  1426. #endif
  1427. #ifdef SYSV
  1428.     double drand48();
  1429.     return( (int) (drand48() * 6.0) + 1.0);
  1430. #endif
  1431. #ifdef XENIX
  1432.     return( rand() % 6 + 1);
  1433. #endif
  1434. }
  1435. SHAR_EOF
  1436. fi # end of overwriting check
  1437. if test -f 'subs.c'
  1438. then
  1439.     echo shar: will not over-write existing file "'subs.c'"
  1440. else
  1441. cat << \SHAR_EOF > 'subs.c'
  1442. #include "types.h"
  1443. #include "ext.h"
  1444.  
  1445. char bark[600];
  1446.  
  1447. clrtocol(n)
  1448. int n;
  1449. {
  1450.     int y,x,x1;
  1451.  
  1452.     getyx(stdscr,y,x); x1=x;
  1453.     while(x<=n) mvaddch(y,x++,' ');
  1454.     move(y,x1);
  1455. }
  1456.  
  1457. ind(s,c)
  1458. char *s,c;
  1459. {
  1460.     int i;
  1461.  
  1462.     for(i=0;*s;i++,s++) if(*s==c) break;
  1463.     if(!(*s)) return(-1);
  1464.     else return(i);
  1465. }
  1466.  
  1467. msg(s,y,x)
  1468. char *s;
  1469. {
  1470.     char c;
  1471.  
  1472.     move(y,x); clrtocol(D-1); refresh();
  1473.     printw("%s-More-",s); refresh();
  1474.     while((c=getchar())!=' ') BEEP;
  1475. }
  1476.  
  1477. addline(s)
  1478. char *s;
  1479. {
  1480.     static int acol=1;
  1481.     if(!s) {
  1482.         move(23,1); clrtoeol(); refresh(); acol=1;
  1483.     } else {
  1484.         if(acol+strlen(s) > 70) acol=1;
  1485.         move(23,acol); clrtoeol(); printw("%s ",s); refresh();
  1486.         acol += strlen(s)+1;
  1487.     }
  1488. }
  1489.  
  1490. double getbet(half)
  1491. int half;
  1492. {
  1493.     char c;
  1494.     int nd=0,dot=0,dc=0;
  1495.     double i=0.0,frac=0.0;
  1496.  
  1497.     while(1) {
  1498.         c=getchar();
  1499.         if(c=='\n') {
  1500.             if(frac==0.20||frac==0.70) {BEEP; continue;}
  1501.             else break;
  1502.         }
  1503.         if((c<'0' || c>'9')&&(c!='.')&&(c!=(char)8)&&(c!=ESC)) BEEP;
  1504.         else if(c==ESC) return(-1.0);
  1505.         else if(c=='.') {
  1506.             if(dot==1) BEEP;
  1507.             else {
  1508.                 dot=1;
  1509.                 addch(c); refresh();
  1510.             }
  1511.         } else if(c==(char)8) {
  1512.             if(!nd && (!dc && !dot)) BEEP;
  1513.             if(dc) {
  1514.                 if(frac==0.25) frac=0.20;
  1515.                 else if(frac==0.75) frac=0.70;
  1516.                 else if(frac==0.50 && dc==2) frac=0.50;
  1517.                 else if(frac==0.50) frac=0.0;
  1518.                 else if(frac==0.20) frac=0.0;
  1519.                 else if(frac==0.70) frac=0.0;
  1520.             }
  1521.             if(nd) i = (float) ((int) (i/10.0));
  1522.             if(nd || dc || dot) {
  1523.                 addch((char)8); addch(' '); addch((char)8);
  1524.                 refresh();
  1525.                 if(dc) dc--;
  1526.                 else if(dot && !dc) dot=0;
  1527.                 else if(nd) nd--;
  1528.             }
  1529.         } else {
  1530.             if(dot)
  1531.                 switch(dc) {
  1532.                     case 0: if(c=='2'||c=='5'||c=='7') {
  1533.                             frac=(double)(c-'0')/10.0;
  1534.                             dc++;
  1535.                             addch(c); refresh();
  1536.                         } else BEEP;
  1537.                         break;
  1538.                     case 1:    if(c=='5') {
  1539.                             if(frac==.2||frac==.7) {
  1540.                                 frac=frac+0.05;
  1541.                                 dc++;
  1542.                                 addch(c);
  1543.                                 refresh();
  1544.                             } else BEEP;
  1545.                         } else if(c=='0') {
  1546.                             if(frac==.5) {
  1547.                                 frac=0.5;
  1548.                                 dc++;
  1549.                                 addch(c);
  1550.                                 refresh();
  1551.                             } else BEEP;
  1552.                         } else BEEP;
  1553.                         break;
  1554.                     default:BEEP;
  1555.                 }
  1556.             else {
  1557.                 if(nd==3) {BEEP; continue;}
  1558.                 i = (i*10.0) + c - '0';
  1559.                 nd++;
  1560.                 addch(c); refresh();
  1561.             }
  1562.         }
  1563.     }
  1564.     return(i+frac);
  1565. }
  1566.  
  1567. announce(s)
  1568. char *s;
  1569. {
  1570.     if(!s) bark[0]=0;
  1571.     else strcat(bark,s);
  1572. }
  1573.  
  1574. pr_an()
  1575. {
  1576.     int i=0,j=0,k=0,l,K=11;
  1577.     char temp[81];
  1578.  
  1579.     line[0]=0;
  1580.     while(bark[i]) {
  1581.         while(bark[i] != '~') temp[j++]=bark[i++];
  1582.         i++;
  1583.         temp[j]=0;
  1584.         l=K+((D-7-K-strlen(temp))/2);
  1585.         move(18,K); clrtocol(D-1); refresh();
  1586.         msg(temp,18,l);
  1587.         j=0;
  1588.     }
  1589.     move(18,K); clrtocol(D-1); refresh();
  1590. }
  1591.  
  1592. update(force)
  1593. int force;
  1594. {
  1595.     if(otot!=total || olos!=loss || owin!=wins || force) {
  1596.         move(20,6); clrtocol(D-1); refresh();
  1597.         printw("Rack:%.2f",total);
  1598.         printw("  Winnings:%.2f",wins);
  1599.         printw("  Losses:%.2f",loss);
  1600.         refresh();
  1601.     }
  1602.     otot=total; olos=loss; owin=wins;
  1603. }
  1604.  
  1605. roll()
  1606. {
  1607.     int i,k,l;
  1608.  
  1609.     announce(0);
  1610.     mvaddstr(10,2,"-------");
  1611.     mvaddstr(11,2,"|     |");
  1612.     mvaddstr(12,2,"|     |");
  1613.     mvaddstr(13,2,"|     |");
  1614.     mvaddstr(14,2,"-------");
  1615.     mvaddstr(15,2,"-------");
  1616.     mvaddstr(16,2,"|     |");
  1617.     mvaddstr(17,2,"|     |");
  1618.     mvaddstr(18,2,"|     |");
  1619.     mvaddstr(19,2,"-------");
  1620.     if(cheat) {
  1621.         spots(dice[0],11,3);
  1622.         spots(dice[1],16,3);
  1623.     } else for(i=0;i<10;i++) {
  1624.         dice[0]=get_rand();
  1625.         dice[1]=get_rand();
  1626.         spots(dice[0],11,3);
  1627.         spots(dice[1],16,3);
  1628.         refresh();
  1629.     }
  1630.     sum=dice[0]+dice[1];
  1631. }
  1632.  
  1633. spots(i,y,x)
  1634. int i,y,x;
  1635. {
  1636.     switch(i) {
  1637.         case 1:
  1638.             mvaddstr(y,x,"     ");
  1639.             mvaddstr(y+1,x,"  o  ");
  1640.             mvaddstr(y+2,x,"     ");
  1641.             break;
  1642.         case 2:
  1643.             mvaddstr(y,x,"o    ");
  1644.             mvaddstr(y+1,x,"     ");
  1645.             mvaddstr(y+2,x,"    o");
  1646.             break;
  1647.         case 3:
  1648.             mvaddstr(y,x,"o    ");
  1649.             mvaddstr(y+1,x,"  o  ");
  1650.             mvaddstr(y+2,x,"    o");
  1651.             break;
  1652.         case 4:
  1653.             mvaddstr(y,x,"o   o");
  1654.             mvaddstr(y+1,x,"     ");
  1655.             mvaddstr(y+2,x,"o   o");
  1656.             break;
  1657.         case 5:
  1658.             mvaddstr(y,x,"o   o");
  1659.             mvaddstr(y+1,x,"  o  ");
  1660.             mvaddstr(y+2,x,"o   o");
  1661.             break;
  1662.         case 6:
  1663.             mvaddstr(y,x,"o   o");
  1664.             mvaddstr(y+1,x,"o   o");
  1665.             mvaddstr(y+2,x,"o   o");
  1666.             break;
  1667.     }
  1668. }
  1669.  
  1670. mark_point(n)
  1671. int n;
  1672. {
  1673.     mvaddstr(4,pcol[n],"----");
  1674.     refresh();
  1675.     point=n;
  1676.     sprintf(line,"The Point is %d! ~",point);
  1677.     announce(line);
  1678.     move_place(n);
  1679. }
  1680.  
  1681. cl_point()
  1682. {
  1683.     mvaddstr(4,pcol[point],"    ");
  1684.     refresh();
  1685.     point=0;
  1686. }
  1687.  
  1688. bar_the_12()
  1689. {
  1690.     int i,j=0;
  1691.  
  1692.     for(i=0;i<11;i++) if(dcome[i]!=0.0) j=1;
  1693.     if(dcomeb!=0.0) j=1;
  1694.     if(j || (dont!=0.0 && !point)) announce("Bar the Dont's! ~");
  1695. }
  1696. SHAR_EOF
  1697. fi # end of overwriting check
  1698. if test -f 'ext.h'
  1699. then
  1700.     echo shar: will not over-write existing file "'ext.h'"
  1701. else
  1702. cat << \SHAR_EOF > 'ext.h'
  1703. extern int pcol[11];
  1704.  
  1705. extern char *keys,line[81];
  1706. extern char *nums[];
  1707. extern char *Bets[];
  1708.  
  1709. extern double total, wins, loss, otot, olos, owin, handle;
  1710.  
  1711. extern double pass,comeb,come[11],odds[11];
  1712. extern double dont,dcomeb,dcome[11],lodds[11];
  1713. extern double place[11],field;
  1714. extern double hways[11],aseven,acraps,eeyo,boxcars,aces,aceduece;
  1715.  
  1716. extern int dice[2],sum,point,cheat;
  1717. extern int plcpays[11][2];
  1718. extern int op[11][2];
  1719. extern int hp[11][2];
  1720. extern int fpays[13];
  1721.  
  1722. extern long numbets;
  1723. SHAR_EOF
  1724. fi # end of overwriting check
  1725. if test -f 'types.h'
  1726. then
  1727.     echo shar: will not over-write existing file "'types.h'"
  1728. else
  1729. cat << \SHAR_EOF > 'types.h'
  1730. #include <curses.h>
  1731. #include <signal.h>
  1732. #define BEEP    putchar((char)7)
  1733. #define ESC    (char)27
  1734. #define LIMIT    500.00
  1735. #define SLIMIT    1000.00
  1736. #define R    0
  1737. #define C    1
  1738. #define D    C+62
  1739. #define PASS    0
  1740. #define COME    1
  1741. #define DONT    2
  1742. #define DCOME    3
  1743. #define ODDS    4
  1744. #define FIELD    5
  1745. #define PLACE    6
  1746. #define LODDS    7
  1747. #define HWAY    8
  1748. #define ASEVEN    9
  1749. #define    ACRAPS    10
  1750. #define    TWO    11
  1751. #define    THREE    12
  1752. #define    EEYO    13
  1753. #define TWELVE    14
  1754. #define CHEAT    15
  1755. #define QUIT    16
  1756. #define HELP    17
  1757. #define SHELL    18
  1758. #define ROLL    19
  1759. #define REFRESH 20
  1760. SHAR_EOF
  1761. fi # end of overwriting check
  1762. #    End of shell archive
  1763. exit 0
  1764.